var CaseTableList = {layerIndex: -1};

CaseTableList.caseDetails = function (id) {
    var index = layer.open({
        type: 2,
        title: '病例详情',
        area: ['90%', '90%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/case_details/' + id
    });
    this.layerIndex = index;
};

CaseTableList.updateCase = function (id) {
    var customerId=document.getElementById("customerId").value;
    var cri=id+","+customerId;
    var index = layer.open({
        type: 2,
        title: '病例修改',
        area: ['100%', '100%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/update/' + cri
    });
    this.layerIndex = index;
};

CaseTableList.caseLog = function (id) {
    var index = layer.open({
        type: 2,
        title: '病例操作日志',
        area: ['80%', '80%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/caseLog/' + id
    });
    this.layerIndex = index;
};

CaseTableList.caseLogs = function () {
    var reservationsId=document.getElementById("reservationsId").value;
    var index = layer.open({
        type: 2,
        title: '病例操作日志',
        area: ['80%', '80%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/caseLogs/' + reservationsId
    });
    this.layerIndex = index;
};

CaseTableList.deleteCase = function (id) {
    if (confirm("确定要删除病历吗?")) {
        var customerId = document.getElementById("customerId").value;
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/deleteCase",
            type: "post",
            data: {
                id: id,
                customerId: customerId
            },
            success: function (data) {
                Feng.success('操作成功!');
                window.parent.location.href = Feng.ctxPath + '/doctorLooked/doctor_seeDiagnosis/' + customerId + '/' + 1
            },
            error: function (data) {
                alert('没有权限，请联系管理员!');
            }
        });
    }
};

CaseTableList.close = function () {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
};

CaseTableList.addCase = function () {
    var customerId = $("#customerId").val();
    var customerStatus = $("#customerStatus").val();
    var cc = customerId + "," + customerStatus
    var index = layer.open({
        type: 2,
        title: '全部病历',
        area: ['100%', '100%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/add_case/' + cc
    });
    this.layerIndex = index;
};

CaseTableList.addoblog = function () {
    var index = layer.open({
        type: 2,
        title: '新增病历模板类别',
        area: ['50%', '50%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/addoblog'
    });
    this.layerIndex = index;
};

CaseTableList.prints = function (ids) {
    console.log(ids);
    var index = layer.open({
        type: 2,
        title: '打印病历',
        area: ['70%', '95%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_print/' + ids
    });
    this.layerIndex = index;
};

CaseTableList.printss = function (ids) {
    console.log(ids);
    var index = layer.open({
        type: 2,
        title: '打印病历',
        area: ['70%', '95%'], //宽高
        fix: true, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/doctorLooked/doctor_prints/' + ids
    });
    this.layerIndex = index;
};

CaseTableList.check = function () {// 检查是否选中
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        CaseTableList.seItem = selected[0];
        return true;
    }
};

CaseTableList.search = function () {
    CaseTableList.table.refresh();
};

CaseTableList.check = function () {// 检查是否选中
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        CaseTableList.seItem = selected[0];
        return true;
    }
};

CaseTableList.print = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '打印',
            area: ['90%', '90%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/doctorLooked/to_print/' + CaseTableList.seItem.id // 传入选中行的客户ID

        });
        this.layerIndex = index;
    }
};

$(".details").click(function () {
    $(this).children().toggle();
    $(this).parent().parent().siblings().children('.doctorHide').toggle();
    $(this).parent().siblings().toggle();
    $(this).parents('.fold').siblings('.foldBox').toggle();
});